/*
 * =====================================================================================
 *    Description:  imitate niyisuai's solution
 *        Version:  1.0
 *        Created:  09/15/2012 12:46:28 AM
 * =====================================================================================
 */
#include	<string.h>
#include	<stdio.h>
#include	<algorithm>

static int sticks[96] = {0x00};
static int choosen[96] = {0x00};

static int origCount, origLen;
static int stickNo, sum;

bool cmp(int a, int b)
{
    return a > b;
}

//the state presented by (currStickCnt,currStickLen, curridx), use start to elimiate
bool searchAns(int stickCnt, int stickLen, int idx)
{
    if (stickCnt == origCount)
        return true;
    if (stickLen == origLen)
        return searchAns(stickCnt+1, 0, 0);
    if (idx >= stickNo)
        return false;

    bool res = false;
    int pre = -1;
    for (int k = idx; k < stickNo; ++k)
    {
        if (choosen[k] != 0)
            continue;
        if (sticks[k] + stickLen > origLen)
            continue;
        if (sticks[k] == pre)
            continue;
        pre = sticks[k];
        choosen[k] = 1;
        res = searchAns(stickCnt, sticks[k]+stickLen, k+1);
        if (!res) {
            choosen[k] = 0;
        } else 
            break;
        // this is very important, from 0 whether choose what, it must be true
        if (idx == 0)
            return false;
    }
    return res;
}

int main()
{
    while (scanf("%d", &stickNo) == 1 && stickNo != 0) {
        sum = 0;
        for (int i = 0; i < stickNo; ++i) {
            scanf("%d", &sticks[i]);
            sum += sticks[i];
        }
        std::sort(sticks, sticks+stickNo, cmp);

        int candidate;
        for (candidate = sticks[0]; candidate <= sum; ++candidate)
        {
            if (sum % candidate != 0)
                continue;
            origCount = sum / candidate;
            origLen = candidate;
            memset(choosen, 0x00, sizeof(choosen));
            bool res = searchAns(0, 0, 0);
            if (res)
            {
                printf ( "%d\n", candidate);
                break;
            }
        }
    }

}
